﻿using NLog;
using System.ComponentModel;

namespace Common
{
    public static class LogHelper
    {
        private static Logger logger = LogManager.GetCurrentClassLogger();
        /// <summary>
        /// 添加日志
        /// </summary
        /// <param name="nLogLevel">日志类型</param>
        /// <param name="cause">原因</param>
        public static void WriteLog(NLogLevel nLogLevel, string cause)
        {
            switch (nLogLevel)
            {
                case NLogLevel.HTTP:
                    logger.Trace(cause);
                    break;
                case NLogLevel.Debug:
                    logger.Debug( cause);
                    break;
                case NLogLevel.Info:
                    logger.Info(cause);
                    break;
                case NLogLevel.Warn:
                    logger.Warn(cause);
                    break;
                case NLogLevel.Error:
                    logger.Error(cause);
                    break;
                case NLogLevel.Fatal:
                    logger.Fatal(cause);
                    break;
                default:
                    break;
            }
        }
        /// <summary>
        /// 日志信息
        /// </summary>
        public  enum NLogLevel
        {
            /// <summary>
            /// 跟踪信息
            /// </summary>
            [Description("跟踪信息")]
            HTTP,
            /// <summary>
            /// 调试信息
            /// </summary>
            [Description("调试信息")]
            Debug,
            /// <summary>
            /// 一般信息
            /// </summary>
            [Description("一般信息")]
            Info,
            /// <summary>
            /// 警告
            /// </summary>
            [Description("警告")]
            Warn,
            /// <summary>
            /// 错误
            /// </summary>
            [Description("错误")]
            Error,
            /// <summary>
            /// 严重错误
            /// </summary>
            [Description("严重错误")]
            Fatal
        }
    }
}